package com.mrlv.rabbitmq;

import java.util.concurrent.CountDownLatch;

/**
 * @author Mrlv
 * @version 1.0
 * @description: 闭锁
 * @date 2021年11月18日 18:30
 */
public class CountDownLatchDemo {

    public static void main(String[] args) throws InterruptedException {

        CountDownLatch countDownLatch = new CountDownLatch(10);
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                System.out.println(Thread.currentThread().getName() + "离开教室");
                countDownLatch.countDown();
                }, String.valueOf(i)).start();
        }
        countDownLatch.await();
        System.out.println("班长关门");
    }
}
